import torch
from torch.nn import Parameter

if torch.backends.mps.is_available():
    mps_device = torch.device('mps')
    device = torch.device('mps')

    # 创建一个张量并将其包装为一个参数
    param = torch.nn.Parameter(torch.Tensor(1).to(device))
    x = torch.ones(1, device=mps_device)
    print(x)
else:
    print("MPS device not found.")

'''
    /Users/liuzexiang/Downloads/数据/neural-datalog-through-time/venv/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py --mode=client --host=127.0.0.1 --port=53774 

    import sys; print('Python %s on %s' % (sys.version, sys.platform))
    sys.path.extend(['/Users/liuzexiang/Downloads/neural-datalog-through-time'])
    
    PyDev console: starting.
    
    Python 3.12.2 (v3.12.2:6abddd9f6a, Feb  6 2024, 17:02:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
    >>> runfile('/Users/liuzexiang/Downloads/neural-datalog-through-time/ndtt/run/train.py', args=['-d', 'iptvsmall', '-db', 'singled8', '-gpu'], wdir='/Users/liuzexiang/Downloads/neural-datalog-through-time/ndtt/run')
    mp num threads in torch : 8
    reading domain knowledge and data...
    init neural datalog database
    init datalog plus database...
    time to init datalog database is 0.30
    load data with split specs : [('train', 1.0), ('dev', 1.0)]
    load 100.000000% of train data
    1 sequences left for train
    load 100.000000% of dev data
    1 sequences left for dev
    load temporal database with split specs : ['train', 'dev']
    load tdb for 1 train seqs
    load previously cached temporal databases
    only first 1 are useful, 0 (of 1) are discarded
    it takes 0.88 seconds
    load tdb for 1 dev seqs
    load previously cached temporal databases
    only first 1 are useful, 0 (of 1) are discarded
    it takes 1.44 seconds
    update params after loading temporal database
    time to update params is 101.66
    time spent on initializatin : 105.34
    start training ... 
    
    进程已结束，退出代码为 137 (interrupted by signal 9:SIGKILL)

'''
